import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class j2me extends MIDlet implements CommandListener{
	private Display display = Display.getDisplay(this);//display显示到屏幕上
	private Form form =new Form("Hello,World!!");
	private Command cmd1 = new Command("back",Command.BACK,0);
	private Command cmd2 = new Command("exit",Command.EXIT,1);
	private Command cmd3 = new Command("canel",Command.CANCEL,2);
	private Command cmd4 = new Command("ok",Command.OK,3);
	public j2me() {
		// TODO Auto-generated constructor stub
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		
		
		
	    
	
        StringItem str = new StringItem("HI"," helloworld!");
        form.append(str);
		//TextBox tb = new TextBox("hello","Hello world",100,TextField.ANY);
        form.addCommand(cmd1);
        form.addCommand(cmd2);
        form.addCommand(cmd3);
        form.addCommand(cmd4);
        form.setCommandListener(this);
       
        display.setCurrent(form);
	}

	public void commandAction(Command cmd, Displayable d) {
		// TODO Auto-generated method stub
		Alert error;
		if(cmd.getCommandType() == Command.BACK)
		{
			System.out.print("1");
			error = new Alert("error","无法返回！",null,AlertType.ERROR);
			//error.setTimeout(300);
			display.setCurrent(error,form);
		}
	}

}
